package cn.rxls.community.service.impl;

import cn.rxls.community.entity.SysConfig;
import cn.rxls.community.mapper.SysConfigMapper;
import cn.rxls.community.service.SysConfigService;
import cn.rxls.community.vo.sysConfig.SysConfigVO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Optional;

/**
 * 配置选项(SysConfig)表服务实现类
 *
 */
@Service("sysConfigService")
@Transactional
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements SysConfigService {

    private final SysConfigMapper sysConfigMapper;

    SysConfigServiceImpl(SysConfigMapper sysConfigMapper){
        this.sysConfigMapper = sysConfigMapper;
    }

    /**
     * 根据类型查询
     *
     * @param category 类型
     * @return 单条信息
     */
    @Override
    public String selectDetailByCategory(String category) {
        LambdaQueryWrapper<SysConfig> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SysConfig::getConfigMsg,category)
                .select(SysConfig::getConfigContent);
        SysConfig sysConfig = sysConfigMapper.selectOne(wrapper);
        return  sysConfig.getConfigContent();
    }
}

